from sqlalchemy import Column, String, Text, Boolean, Integer, ForeignKey, DateTime
from sqlalchemy.sql import func
from sqlalchemy.orm import relationship
from ..database import Base

class Prompt(Base):
    __tablename__ = 'prompts'

    id = Column(String, primary_key=True, index=True)
    title = Column(String, index=True)
    content = Column(Text)
    description = Column(Text)
    user_id = Column(String, ForeignKey('users.id'))
    created_at = Column(DateTime(timezone=True), server_default=func.now())
    updated_at = Column(DateTime(timezone=True), server_default=func.now(), onupdate=func.now())  # 添加server_default
    is_public = Column(Boolean, default=True)
    version = Column(String, default="1.0.0")  # 修改为String类型，默认值改为字符串
    tags = Column(String)
    model_id = Column(String)
    cover_img = Column(String)

    # 与用户的关系
    user = relationship('User')